import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    // =============  login  ================
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../views/login/Login')
    },

    // ============  admin  ===============
    {
        path: '/adminIndex',
        name: 'AdminIndex',
        redirect: '/home',
        component: () => import('../views/admin/AdminIndex'),
        children: [
            {
                path: 'home',
                name: 'Home',
                component: () => import('../views/admin/Home')
            },
            {
                path: 'student',
                name: 'Student',
                component: () => import('../views/admin/Student')
            },
            {
                path: 'department',
                name: 'Department',
                component: () => import('../views/admin/Department')
            },
            {
                path: 'course',
                name: 'Course',
                component: () => import('../views/admin/Course')
            },
            {
                path: 'teacher',
                name: 'Teacher',
                component: () => import('../views/admin/Teacher')
            },
            {
                path: 'sct',
                name: 'Sct',
                component: () => import('../views/admin/Sct')
            },
            {
                path: 'totalChart',
                name: 'TotalChart',
                component: () => import('../views/admin/TotalChart')
            },
            {
                path: 'studentChart',
                name: 'StudentChart',
                component: () => import('../views/admin/StudentChart')
            },
            {
                path: 'timeSet',
                name: 'TimeSet',
                component: () => import('../views/admin/TimeSet')
            },
        ]
    },

    // ============   student   ==============
    {
        path: '/studentIndex',
        name: 'StudentIndex',
        redirect: '/home',
        component: () => import('../views/student/StudentIndex'),
        children: [
            {
                path: 'home',
                name: 'Home',
                component: () => import('../views/student/Home')
            },
            {
                path: 'updateInfo',
                name: 'UpdateInfo',
                component: () => import('../views/student/UpdateInfo')
            },
            {
                path: 'selectCourse',
                name: 'SelectCourse',
                component: () => import('../views/student/SelectCourse')
            },
            {
                path: 'updatePassword',
                name: 'UpdatePassword',
                component: () => import('../views/student/UpdatePassword')
            },
            {
                path: 'courseRecord',
                name: 'CourseRecord',
                component: () => import('../views/student/CourseRecord')
            }
        ]
    },

    // ===========   teacher   ===========
    {
        path: '/teacherIndex',
        name: 'TeacherIndex',
        redirect: '/home',
        component: () => import('../views/teacher/TeacherIndex'),
        children: [
            {
                path: 'home',
                name: 'Home',
                component: () => import('../views/teacher/Home')
            },
            {
                path: 'giveGrade',
                name: 'GiveGrade',
                component: () => import('../views/teacher/GiveGrade')
            },
            {
                path: 'updateInfo',
                name: 'UpdateInfo',
                component: () => import('../views/teacher/UpdateInfo')
            },
            {
                path: 'updatePassword',
                name: 'UpdatePassword',
                component: () => import('../views/teacher/UpdatePassword')
            },
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
